<!DOCTYPE html>
<html>
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <meta name="viewport" content="width=device-width,initial-scale=1,user-scalable=0,minimum-scale=1.0,maximum-scale=1.0" />
    <meta name="author" content="火星科技 http://mars2d.cn " />
    <meta name="apple-touch-fullscreen" content="yes" />
    <meta name="apple-mobile-web-app-capable" content="yes" />
    <meta name="apple-mobile-web-app-status-bar-style" content="black" />
    <meta name="format-detection" content="telephone=no" />
    <meta name="x5-fullscreen" content="true" />
    <meta http-equiv="X-UA-Compatible" content="IE=Edge,chrome=1" />
    <!-- 标题及搜索关键字 -->
    <meta name="keywords" content="火星科技,cesium,3D,GIS,marsgis,二维,地图,地球,开发,框架,系统,示例,资料,模型,离线,外包,合肥,安徽,中国" />
    <meta
      name="description"
      content="火星科技 合肥火星 合肥火星科技 合肥火星科技有限公司 leaflet leaflet框架 leaflet开发 cesium cesium开发 cesium框架 二维 地图 模型  gis marsgis 地图离线 地图开发 地图框架 地图外包 框架 开发 外包  地图离线 二维地图 二维地图 全景漫游 地理信息系统 云GIS 二维GIS GIS平台 WebGIS"
    />

    <link rel="shortcut icon" type="image/x-icon" href="//mars2d.cn/favicon.ico" />
    <title>control 控件 | Mars2D | 地理信息平台 | 火星科技 | 合肥火星科技有限公司</title>

    <!--第三方lib-->
    <script
      type="text/javascript"
      src="../lib/include-lib.js"
      libpath="../lib/"
      include="jquery,font-awesome,bootstrap,layer,haoutil,turf,mars2d"
    ></script>

    <link href="css/style.css" rel="stylesheet" />
  </head>

  <body class="dark">
    <div id="mars2dContainer" class="mars2d-container"></div>

    <script type="text/javascript">
      "use script"; //开发环境建议开启严格模式

      $(document).ready(function () {
        initMap();
      });

      function initMap() {
        //添加控件有2种方式:

        //方式1：在创建地图前的传参中配置control参数
        var map = new mars2d.Map("mars2dContainer", {
          zoom: 5,
          center: { lng: 110.522461, lat: 37.509726 },
          control: {
            //以下是Leaflet所支持的控件相关的options
            scale: true,
            zoom: { position: "bottomright" },
            layers: { position: "topleft" },

            //以下是mars2d.control定义的控件
            defaultContextMenu: true, //右键菜单
            locationBar: {
              crs: "CGCS2000_GK_Zone_3",
              template: "<div>经度:{lng}</div> <div>纬度:{lat}</div> <div>横{crsx}  纵{crsy}</div> <div>层级:{level}</div>",
            },
            toolBar: { position: "bottomright" },
          },
          basemaps: [
            {
              name: "蓝色地图",
              type: "arcgis",
              url: "http://map.geoq.cn/ArcGIS/rest/services/ChinaOnlineStreetPurplishBlue/MapServer",
              chinaCRS: "GCJ02",
              show: true,
            },
          ],
          operationallayers: [
            {
              name: "全国省界",
              type: "geojson",
              url: "http://data.mars2d.cn/file/geojson/areas/100000_full.json",
              symbol: {
                type: "polyline",
                styleOptions: {
                  width: 2,
                  color: "#ff0000",
                  dashArray: "5 10",
                },
              },
              popup: "all",
            },
          ],
        });

        //方式2：在创建地图后按需调用addControl添加(直接new对应type类型的控件)
        var overviewMap = new mars2d.control.OverviewMap({
          position: "topright",
          mapOptions: {
            basemaps: [
              {
                type: "tile",
                url: "https://a.tile.openstreetmap.org/{z}/{x}/{y}.png",
                show: true,
              },
            ],
          },
        });
        map.addControl(overviewMap);
      }
    </script>
  </body>
</html>
